<?php
class CriteriosBitacorasController extends AppController {

	var $name = 'CriteriosBitacoras';
	var $helpers = array('Access');
	
	function index() {
		$usuario_activo = $this->Access->getMy('username');
		//Verificacion de sesion del sistema		
		if(!$usuario_activo){
			$this->Session->setFlash(__('Por favor inicie sesion', true));
			$this->redirect(array('controller'=>'users','action' => 'login'));
		}
		$this->CriteriosBitacora->recursive = 0;
		$this->set('criteriosBitacoras', $this->paginate());
	}

	function view($id = null) {
		$usuario_activo = $this->Access->getMy('username');
		//Verificacion de sesion del sistema		
		if(!$usuario_activo){
			$this->Session->setFlash(__('Por favor inicie sesion', true));
			$this->redirect(array('controller'=>'users','action' => 'login'));
		}
		if (!$id) {
			$this->Session->setFlash(__('Invalid criterios bitacora', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('criteriosBitacora', $this->CriteriosBitacora->read(null, $id));
	}

	function add() {
		$usuario_activo = $this->Access->getMy('username');
		//Verificacion de sesion del sistema		
		if(!$usuario_activo){
			$this->Session->setFlash(__('Por favor inicie sesion', true));
			$this->redirect(array('controller'=>'users','action' => 'login'));
		}
		if (!empty($this->data)) {
			$this->CriteriosBitacora->create();
			if ($this->CriteriosBitacora->save($this->data)) {
				$this->Session->setFlash(__('The criterios bitacora has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The criterios bitacora could not be saved. Please, try again.', true));
			}
		}
	}

	function edit($id = null) {
		$usuario_activo = $this->Access->getMy('username');
		//Verificacion de sesion del sistema		
		if(!$usuario_activo){
			$this->Session->setFlash(__('Por favor inicie sesion', true));
			$this->redirect(array('controller'=>'users','action' => 'login'));
		}
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid criterios bitacora', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->CriteriosBitacora->save($this->data)) {
				$this->Session->setFlash(__('The criterios bitacora has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The criterios bitacora could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->CriteriosBitacora->read(null, $id);
		}
	}

	function delete($id = null) {
		$usuario_activo = $this->Access->getMy('username');
		//Verificacion de sesion del sistema		
		if(!$usuario_activo){
			$this->Session->setFlash(__('Por favor inicie sesion', true));
			$this->redirect(array('controller'=>'users','action' => 'login'));
		}
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for criterios bitacora', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->CriteriosBitacora->delete($id)) {
			$this->Session->setFlash(__('Criterios bitacora deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Criterios bitacora was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>